home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MacGofer 0.22d / MacGofer 0.22d Release / Gofer Documentation / Gofer Manual / appx_c < prev    next >
Text File  |  1991-12-30  |  9KB  |  116 lines

  1.  
  2.  
  3. Introduction to Gofer         APPENDIX C: RELATIONSHIP WITH HASKELL 1.1         
  4.  
  5.  
  6. APPENDIX C: RELATIONSHIP WITH HASKELL 1.1
  7.  
  8. The language supported by Gofer is both syntactically and  semantically
  9. similar to that of  the  functional  programming  language  Haskell  as
  10. defined in the report  for  Haskell  version  1.1  [5].   This  section
  11. details the differences between the two languages, outlined briefly  in
  12. section 2.
  13.  
  14. Haskell features not included in Gofer:
  15. ---------------------------------------
  16.   o  Modules
  17.  
  18.   o  Arrays
  19.  
  20.   o  Derived instances for standard classes -- the ability to construct
  21.      instances of particular classes automatically.
  22.  
  23.   o  Default mechanism for eliminating unresolved overloading involving
  24.      numeric and standard classes.   Since  Gofer  is  an  experimental
  25.      system, it can be  used  with  a  range  of  completely  different
  26.      prelude files; there is no concept of `standard classes'.
  27.  
  28.   o  Overloaded numeric constants.  In  the  absence  of  a  defaulting
  29.      mechanism  as  mentioned  in  the  previous  item,  problems  with
  30.      unresolved overloading make implicitly typed programming involving
  31.      numeric constants impractical in an interpreter based system.
  32.  
  33.   o  Full range of numeric types  and  classes.   Gofer  has  only  two
  34.      primitive numeric types Int and Float (the second of which is  not
  35.      supported in the PC version).  Although is would  be  possible  to
  36.      modify the standard prelude so that  Gofer  uses  the  same  class
  37.      hierarchy as Haskell, this is unnecessarily sophisticated for  the
  38.      intended uses of Gofer.
  39.  
  40.   o  Datatype definitions in Haskell may involve class constraints such
  41.      as:
  42.  
  43.               data  Ord a => Set a = Set [a]
  44.  
  45.      It is  not  clear  how  such  constraints  should  be  interpreted
  46.      (particularly in the light of the  extended  form  of  constraints
  47.      used by Gofer) in such a way to  make  them  useful  whilst  avoid
  48.      unwanted ambiguity problems.
  49.  
  50.  
  51. Gofer features not supported in Haskell:
  52. ----------------------------------------
  53.   o  Type classes may have multiple parameters.
  54.  
  55.   o  Predicates  in  type  expressions  may  involve   arbitrary   type
  56.      expressions, not just type variables as used in Haskell.
  57.  
  58.   o  Instances of type classes can be defined at  non-overlapping,  but
  59.      otherwise arbitrary types, as described in section 14.2.5.
  60.  
  61.   o  List comprehensions  may include  local definitions,  specified by
  62.  
  63.  
  64.                                       111
  65.  
  66.  
  67.  
  68.  
  69. Introduction to Gofer         APPENDIX C: RELATIONSHIP WITH HASKELL 1.1         
  70.  
  71.  
  72.      qualifiers of the form <pat>=<expr> as described in section 10.2.
  73.  
  74.   o  No restrictions are placed on the form of predicates  that  appear
  75.      in the context for a class of instance declaration.   This  has  a
  76.      number  of  consequences,  including  the  possibility  of   using
  77.      (mutually)  recursive  groups  of  dictionaries,  but  means  that
  78.      decidability of the predicate entailment  relation  may  be  lost.
  79.      This is not a great problem  in  practice,  since  all  dictionary
  80.      construction  is  performed  before  evaluation   and   supposedly
  81.      non-terminating dictionary constructions will actually generate an
  82.      error due to the limited amount of  space  available  for  holding
  83.      dictionaries (see section 14.4.2).
  84.  
  85.  
  86. Other differences:
  87. ------------------
  88.   o  Whilst superficially similar the approach to type classes in Gofer
  89.      is quite different to that used in Haskell.   In  particular,  the
  90.      approach used in Gofer ensures that all necessary dictionaries are
  91.      constructed before the evaluation of an expression begins,  rather
  92.      than being built (possibly several times) during the evaluation as
  93.      is the case with Haskell.  See section 14 and reference  [11]  for
  94.      further details.
  95.  
  96.   o  Input/Output facilities - Gofer supports  only  a  subset  of  the
  97.      requests available in Haskell.  In principal, it should not be too
  98.      difficult to add most of the remaining forms of request (with  the
  99.      exception of those associated with binary files)  to  Gofer.   The
  100.      principal motivation for including the I/O facilities in Gofer was
  101.      to  make  it  possible  to  experiment  with  simple   interactive
  102.      programs.
  103.  
  104.   o  In Gofer, unary minus has greater  precedence  than  any  operator
  105.      symbol, but lower than that of function application.  In  Haskell,
  106.      the precedence of unary minus is the same as  that  of  the  infix
  107.      (subtraction) operator of the same name.
  108.  
  109.   o  In Haskell, the character `-'  can  only  be  used  as  the  first
  110.      character of an operator symbol.  In  Gofer,  this  character  may
  111.      appear  in  any  position  in  an  operator  (except  for  symbols
  112.      beginning with "--", which indicates the start of a comment).  The
  113.      only problems that I am aware  of  with  this  is  that  a  lambda
  114.      expression such as "\-2->2" will be parsed as such  by  a  Haskell
  115.      system, but cause a syntax error in Gofer.  This  form  of  lambda
  116.      expression is sufficiently unusual that I do